package initialize

import (
	"uploadSvc/config"
	"uploadSvc/global"

	"gorm.io/gorm"
)

func DBList() {
	dbMap := make(map[string]*gorm.DB)
	for _, info := range global.NS_CONFIG.DBList {
		if info.Disable {
			continue
		}
		switch info.Type {
		case "dm":
			dbMap[info.AliasName] = GormDMByConfig(config.DM{GeneralDB: info.GeneralDB})
		default:
			dbMap[info.AliasName] = GormDMByConfig(config.DM{GeneralDB: info.GeneralDB})
		}

	}
	if db, ok := dbMap["nanshandm"]; ok {
		global.NS_DB = db
	}
	global.NS_DBList = dbMap
}
